class Cache {
    constructor(count) {
        this.count = count
        this.data = new Map()
        //记录缓存顺序
        this.cord = []
    }

    add(k, v) {
        if (this.data.size >= this.count) {
            //超过最大缓存
            this.data.delete(this.cord.shift())
        }
        this.cord.push(k)
        this.data.set(k, v)
    }

    get(k) {
        return this.data.get(k)
    }

    has(k) {
        return this.data.has(k)
    }
}
export default Cache